package com.gumanx;

import cpw.mods.fml.common.network.Player;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.effect.EntityLightningBolt;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;

public class ItemStaffLightning extends Item {

	public ItemStaffLightning(int par1) {
		super(par1);
		this.setCreativeTab(CreativeTabs.tabCombat);
	}

	public boolean hasEffect(ItemStack par1ItemStack) {
		return true;
	}

	public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World,
			EntityPlayer par3EntityPlayer) {
		if (!par2World.isRemote) {
			MovingObjectPosition Coord = par3EntityPlayer.rayTrace(500, 1);
			if (Coord != null) {
				EntityLightningBolt Lightning = new EntityLightningBolt(
						par2World, Coord.blockX, Coord.blockY, Coord.blockZ);

				for (int i = 5; i > -5; i--) {
					par2World.spawnEntityInWorld(new EntityLightningBolt(
							par2World, Coord.blockX + i, Coord.blockY,
							Coord.blockZ));
					par2World.addWeatherEffect(Lightning);
				}
			}
		}

		return par1ItemStack;
	}

	public void registerIcons(IconRegister iconReg) {
		itemIcon = iconReg.registerIcon("gumanx:staffLightning");
	}

}